package com.classic.common.simple;

import com.classic.common.MultipleStatusView;
import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.DirectionalLayout;

public class Simple3Ability extends AbsAbility {
    @Override
    void initView() {
        setUIContent(ResourceTable.Layout_ability_simple3);
        ComponentContainer componentContainer = (ComponentContainer) findComponentById(ResourceTable.Id_ll_content);
        mMultipleStatusView = MultipleStatusView.attach(componentContainer);
        initAppBar();
    }
    private void initAppBar() {
        DirectionalLayout backButton = (DirectionalLayout)
                findComponentById(ResourceTable.Id_appBar_backButton_touchTarget);
        backButton.setClickedListener(component -> onBackPressed());
    }
    @Override
    public void onClick(Component component) {
        switch (component.getId()) {
            case ResourceTable.Id_fab_loading:
                loading();
                break;
            case ResourceTable.Id_fab_empty:
                mMultipleStatusView.showEmpty(ResourceTable.Id_empty_retry_view);
                break;
            case ResourceTable.Id_fab_error:
                mMultipleStatusView.showError(ResourceTable.Id_error_retry_view);
                break;
            case ResourceTable.Id_fab_no_network:
                mMultipleStatusView.showNoNetwork(ResourceTable.Id_no_network_retry_view);
                break;
            case ResourceTable.Id_fab_content:
                mMultipleStatusView.showContent();
                break;
        }
        mFloatingActionMenu.toggle(false);
    }
}
